Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

249
Visualizações
In javascript "contructor --> prototype" chain is never ending

While debugging the JavaScript prototype chain I came across that when we define a Constructor function, the constructor-->prototype chain is never-ending, it keeps on expanding. I have attached a screenshot and a sample code also for reference.

function Person(first, last, age, gender, interests) {
this.name = {
'first': first,
'last' : last
 };
 this.age = age;
this.gender = gender;
} 

const person1 = new Person("foo", "bar", 24, "Male")

My question is, does JavaScript access it by reference/walking up the chain or is JavaScript actually storing it in memory

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The chain is not ever-expanding, it contains a circular reference.

As explained on MDN:

Every constructor function has a prototype property whose value is an object containing a constructor property. This constructor property points to the original constructor function.

The following example demonstrates this:

function X() {}

const x = new X();

// test for strict equality
console.log(x.constructor === x.constructor.prototype.constructor); // true

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda